<?php
if($_SESSION['user_id_sess']=="") {
		echo "<script type='text/javascript'> window.location='index.php?signin&url=mylist'; </script>";
	}
require_once 'includes/class.phpmailer.php';

$proId=$_REQUEST['Postfeedback'];
if($_REQUEST['type']=='0')
{
 
$sqlSelItem="select * from tbl_items  where item_id=".$proId."";
$rstSelItem=mysql_query($sqlSelItem);
$rowSelItem=mysql_fetch_array($rstSelItem);

$sqlSelProd="SELECT * FROM tbl_product WHERE product_id='".$rowSelItem['product_id']."'";

}
else
 $sqlSelProd="SELECT * FROM tbl_wholeseller_product WHERE product_id='$proId'";
 
$rstSelProd=mysql_query($sqlSelProd);
$rowSelProd=mysql_fetch_array($rstSelProd);
$productOwner=$rowSelProd['posted_by'];	
$productName=$rowSelProd['product_name'];	
$productDesc=$rowSelProd['product_description'];
$productCategory=$rowSelProd['category_id'];
$productPrice=$rowSelProd['product_price'];
$postedDate=$rowSelProd['posted_date'];
$sellingType=$rowSelProd['selling_type'];
$shipping = number_format($rowSelProd['shipping'],2);
if(!empty($shipping) && $shipping!=0.00)
 $shipping="$".$shipping;
else
 $shipping="Free";
$pimage = getProductImage($proId,'p');
 //echo $pthumb;
if($pimage['thumb']!="") {
	$productThumbnail = $pimage['thumb'];
 }  else {
	$productThumbnail="images/no_image.gif";	
 } 
		  
$catInfo=getCategory($productCategory);
//get user name using function
$proOwnerName = getUser($rowSelProd['posted_by']);

//echo $userId;
//check user already selling this item or not
$sqlSelItem = "SELECT item_id FROM tbl_items WHERE product_id='$proId' 
			   AND seller_id='$userId' AND owner_id='$productOwner'";
$rstSelItem = mysql_query($sqlSelItem) or die(mysql_error());			   
$numSelItem = mysql_num_rows($rstSelItem);
$ownname = getUser($productOwner);

if($_SESSION['user_id_sess']==$productOwner)
{
	$ownname =getUser($_REQUEST['order_by']);
	$productOwner=$_REQUEST['order_by'];	
	
}
if(isset($_REQUEST['comment']))
{
	$comment=$_REQUEST['comment'];
	$rate=$_REQUEST['rate'];
	$comment_to=$_REQUEST['owner_id'];
	$comment_by=$_SESSION['user_id_sess'];
	$post_date=date('Y-m-d');
	//echo "INSERT INTO tbl_feedback set option='$rate',comment='$comment',comm_to='$comment_to',comm_by='$comment_by'";
	$ins_feed=mysql_query("INSERT INTO tbl_feedback values('','$comment','$comment_to','$comment_by','$post_date','$rate')") or die(mysql_error());
	echo "<div style='color:red;margin-left:10px;'>Your Feedback posted successfully!</div>";
}
?>

<script language="javascript">
  function funpostfeedback()
	{
		//alert("hi");
		if(document.getElementById("comment").value=="")
		{
			alert("Please enter comment.");
			return false;
		}
		else
		  return true;
	}

</script>
<style type="text/css">
	span#add-wishlist { color:#0000CC; padding:5px; font-size:12px; }	
</style>


<div id='panel'>
<div class="fulldiv" style="width:700px;">

<div class="fulldiv" style="margin:10px 0px 0px 0px;">
	
<div style="float:left; margin:0px 10px 0px 10px;"><strong class="orangehead">Your Feedback On Transaction </strong></div>

<div class="fullbox_top">&nbsp;</div>
<div class="fullbox_repeat">
<table width="100%" border="0">
  <tr>
    <td class="contentHeader"><div>Please leave honest feedback on your transaction.</div></td>
  </tr>
  <tr>
    <td class="contentHeader"><a href="<?=$base_url?>index.php?feedback=1&owner_id=<?=$productOwner?>"><h2><?=$ownname?></h2></a><br>100%(0)</td>
  </tr>
  <tr>
    <td>
	   <br style="clear:both;"><br>
	   		
	   <form name="frmProductInfo" id="frmProductInfo" method="post">
	   <input type="hidden" name="hidBargain" id="hidBargain">
	   <div style="border:1px solid #CCC;">
         <table width='100%' border='0' align='center' cellspacing='0' cellpadding="0" >
           <tr>
             <td width="16%" rowspan="2" style='vertical-align:middle; padding:5px;background-color:#F5F5F5; text-align:center'><img src="<?php echo $productThumbnail; ?>" /> <div>
             </div></td>
             <td width="37%" style='vertical-align:top; padding:5px;'><?php echo "$productName";?> </td>
             <td width="47%" style='vertical-align:top; padding:5px;'><table width="100%" border="0" cellpadding="1"  cellspacing='1' class="greyBoldCell">
               <tr>
                  <td width="27%">Price</td>
                 <td width="24%">Shipping</td>
               </tr>
               <tr>
                <td>$<?php echo number_format($productPrice,2); ?></td>
                 <td><?php echo $shipping ?></td>
               </tr>
             </table>
              <br /></td>
            </tr>
           <tr>
             <td height="25"  style='padding:5px;'>
			 	
				<?php 
				
				$owntype = printUserType($productOwner);
				
				//$ownname = getUser($productOwner);
				if($_SESSION['user_id_sess']==$productOwner)
					echo "<strong> Buyer </strong> : ".ucfirst($ownname);
				else
					echo "<strong> Owner </strong> : ".ucfirst($ownname);
				
				?> 
			 
			 <br></td>
             
			 <td align="center" style='vertical-align:top; padding:5px;' rowspan="2"><?php if($_SESSION['user_id_sess']=="") { $usr=0; } else { $usr=$_SESSION['user_id_sess'];} ?>
               
			   
			   <br />
               <span id="divAddItemToSeller"></span> </td>
           </tr>
           <tr>
             <td height="25" colspan="2" ><a href="javascript:void(0);" onClick="openWindow('item_viewer.php?prod=<?php echo $proId; ?>&type=p','580','650');"><?php if(getImageCount($proId)!=0) echo getImageCount($proId)." images"  ?></a></td>
           </tr>
         </table>
	     </div>
	   <br>
	   <div style="border:1px solid #CCC;"> 
	  		<table width="100%" align="center" border="0">
				<tr>
					<td><strong>Rate this transaction</strong></td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" >
          					<tr>
						  <td colspan="2">
							Your Options
						  </td>
						</tr>
						<tr>
						  <td width="10%">
							<input type="radio" name="rate" checked="checked" id="rate1" value="1" >
						  </td>
						  <td>
							Great
						  </td>
						</tr>
						<tr>
						  <td width="10%">
							<input type="radio" name="rate" id="rate2" value="2">
						  </td>
						  <td>
							Acceptable
						  </td>
						</tr>
						<tr>
						  <td width="10%">
							<input type="radio" name="rate" id="rate3" value="3">
						  </td>
						  <td>
							Negative
						  </td>
						</tr>
						<script language="javascript">
						  $('#rate'+<?=$_REQUEST['rate']?>).attr('checked','checked');
						</script>
						</table>
					</td>
				</tr>
			</table>
	  </div>
	   <div style="border:1px solid #CCC;"> 			
	   <table width="100%" border="0" align="center">
          
	<tr>
             <td width="47%" valign="top">              
             	<div style="padding:15px;" align="justify"> 
			<strong>Comments on this transaction </strong>
		</div>
	    </td>
	</tr>
	<tr>
           <td >
	   <table  border="0" align="center" width="100%">              
               <tr>
                 <td width="93%" height="28" colspan="2" class="uline">
		   <table align="center" width="90%" border="0">
	                <tr>
                              <td colspan="2" ><textarea name="comment" id="comment" style="height:150px; width:250px; "><?=$comment?></textarea>
				<input type="hidden" name="owner_id" value="<?php echo $productOwner;?>">
                               </td>
                            </tr>
                            <tr>
			      <td width="10%">&nbsp;</td>
                             <td ><input type="submit"  name="btnCommit" value="Post feedback" onClick="return funpostfeedback()"></td>
                            </tr>
                          </table></td>
		  </tr>
		</table>
				 </td>
               </tr>
             </table></td>
           </tr>          
         </table>
		</div>
		<div class="fullbox_bot">&nbsp;</div>
		
		</div>
		
		
	  </form>
	 	</div>  
    
